<?php
class info_chunk  extends chunk_base implements chunk{
	
	var $plantilla="main.html";
	var $plantilla_item="item.html";
	var $scripts=array("js/jquery.min.js",
						"js/mainview.js",
						"js/info.js");
	var $styles=array("css/info.css");
	var $selfpath="";
	var $_plantillaLoaded=false;
	function out($params=array()){
		global $core;
		
		$core->loadClass("imagen");
		
		if(!$this->_plantillaLoaded){
			$this->plantilla=$this->loadPlantilla($this->plantilla);
			$this->plantilla_item=$this->loadPlantilla($this->plantilla_item);
		}
		
		$galeria=$core->getApp("galeria");
		$imagenes=$galeria->getImages();
		$imgs="";
		foreach($imagenes as $k=>$i){
			$img=new imagen($i["id"]);
			$imagenes[$k]["productos"]=$img->getProductos();
			$imgs.=$this->parce($this->plantilla_item,array(
									"SRC"=>$i["path"],
									"ID"=>$i["id"],
									"TITULO"=>$i["nombre"]
									));
			
		}
		
		return $this->parce($this->plantilla,array("IMAGENES"=>$imgs,"INFO"=>json_encode($imagenes)));
	}
}
